import 'dart:convert';

import 'package:common/constant/http_constant.dart';

import 'code_msg_model.dart';

CodeMsgDataModel codeMsgDataModelFromJson(String str) => CodeMsgDataModel.fromMap(json.decode(str));

String codeMsgDataModelToJson(CodeMsgDataModel data) => json.encode(data.toMap());

class CodeMsgDataModel<D> extends CodeMsgModel{

  D? data;

  CodeMsgDataModel([super.code,super.msg,this.data]);

  @override
  Map<String, dynamic> toMap() => {
    HttpConstant.codeKey: code,
    HttpConstant.msgKey: msg,
    HttpConstant.dataKey: data,
  };

  factory CodeMsgDataModel.fromMap(Map<String, dynamic> json) => CodeMsgDataModel(
    json[HttpConstant.codeKey],
    json[HttpConstant.msgKey],
    json[HttpConstant.dataKey]
  );
}